package org.example.intern.entity.dto.res;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.example.intern.utils.Rest;
import org.example.intern.utils.StrUtils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author: world
 * @date: 2022/4/18 17:01
 * @description: 表格接口, 示例
 */
@Data
@ApiModel("表格用例")
public class TableListRes {

    @JsonIgnore
    final static List<String> statusEnums = Arrays.asList("published", "draft", "deleted");

    public TableListRes(){
        // 生成随机数据
        this.id = String.valueOf(StrUtils.getRandomInt(100000));
        this.title = StrUtils.getRandomString(10);
        this.status = statusEnums.get(StrUtils.getRandomInt(statusEnums.size()));
        this.author = StrUtils.getRandomString(10);
        this.displayTime = new Date();
        this.pageViews = StrUtils.getRandomInt(100000);
    }

    @ApiModelProperty("数据id")
    private String id;

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("状态")
    private String status;

    @ApiModelProperty("作者")
    private String author;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("显示时间")
    private Date displayTime;

    @ApiModelProperty("阅读数")
    private Integer pageViews;
}
